#!/bin/sh

# Slackware build script for OS++

# Written by B. Watson (yalhcru@gmail.com)
# Modified by the SlackBuilds.org project.

PRGNAM=atari800_os++
VERSION=${VERSION:-20080924}
ARCH=noarch # actually it's m6502 :)
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

SRCNAM=os++
PRGDIR=osrom

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGDIR
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $PRGDIR
chown -R root:root .

patch -p1 < $CWD/omit_checksum.diff
make osdist OMIT_CHECKSUM=1

mkdir -p $PKG/usr/share/atari800/$PRGNAM
cp osdist $PKG/usr/share/atari800/$PRGNAM/os++.rom

( cd $PKG/usr/share/atari800; ln -s $PRGNAM/os++.rom atarixl.rom )

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp README.* $PKG/usr/doc/$PRGNAM-$VERSION
cp $CWD/README.atari800 $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
